package com.docwei.thansgank.fragment.fuli;

import com.docwei.thansgank.callback.ResultBean;
import com.docwei.thansgank.fragment.IPullDataRequestListener;

/**
 * Created by tobo on 17/8/1.
 * 基类里面处理Presenter与View的关系
 */

public class FuliPresenter extends FuliContract.Presenter<FuliContract.View> {
    public FuliModel mFuliModel=new FuliModel();

    public FuliPresenter(FuliContract.View view) {
        super(view);
    }
    @Override
    public void pullData() {
      mFuliModel.pullFuliData(new IPullDataRequestListener<ResultBean>() {
          @Override
          public void pullDataSuccess(ResultBean data) {
              if(isViewAtteched()) {
                  getUiView().showPullDataSuccess(data);
              }
          }
          @Override
          public void pullDataError(String errMessage) {
              if(isViewAtteched()) {
                  getUiView().showPullDataError(errMessage);
              }
          }
          @Override
          public void before() {
              if(isViewAtteched()) {
                  getUiView().showSwipeRefreshLayout();
              }
          }
          @Override
          public void after() {
              if(isViewAtteched()) {
                  getUiView().hideSwipeRefreshLayout();
              }
          }
      });
    }
}
